import React from 'react'
import { Route, Switch, Redirect, withRouter } from 'react-router-dom'
import { compose } from 'redux'
import Loadable from 'react-loadable'
import Loading from './components/loading'

// md编辑器
const Interview = Loadable({
	loader: () => import('./pages/mdEdit'),
	loading: () => <Loading />,
})

// 头像截取
const Screenshot = Loadable({
	loader: () => import('./pages/screenshot/screenshot'),
	loading: () => null,
})

// G2图像
const Charts = Loadable({
	loader: () => import('./pages/charts'),
	loading: () => null,
})

// 问卷
const Questionnaire = Loadable({
	loader: () => import('./pages/questionnaire'),
	loading: () => null,
})

// demo
const Demo = Loadable({
	loader: () => import('./pages/demo'),
	loading: () => null,
})

// 页签切换
const TabShowDemo = Loadable({
	loader: () => import('./pages/tabPanes/tabShowDemo'),
	loading: () => null,
})

// G6
const G6 = Loadable({
	loader: () => import('./pages/g6'),
	loading: () => null,
})

// Home
const Home = Loadable({
	loader: () => import('./pages/home'),
	loading: () => null,
})

// 我
const Me = Loadable({
	loader: () => import('./pages/me'),
	loading: () => null,
})

class RouteList extends React.Component {
	render() {
		return (
			<Switch>
				<Route path="/interview" component={Interview} />
				<Route path="/screenshot" component={Screenshot} />
				<Route path="/charts" component={Charts} />
				<Route path="/questionnaire" component={Questionnaire} />
				<Route path="/demo" component={Demo} />
				<Route path="/tabShowDemo" component={TabShowDemo} />
				<Route path="/g6" component={G6} />
				<Route path="/home" component={Home} />
				<Route path="/me" component={Me} />
				<Redirect to="/home" />
			</Switch>
		)
	}
}

export default compose(withRouter)(RouteList)
